package org.lanqiao.service.impl;

import javax.annotation.Resource;

import org.lanqiao.dao.IEleInfoDao;
import org.lanqiao.dao.IEleManagerDao;
import org.lanqiao.dao.IEleOpeartorDao;
import org.lanqiao.dao.IEleUserDao;
import org.lanqiao.orm.EleInfo;
import org.lanqiao.orm.EleManager;
import org.lanqiao.orm.EleOpeartor;
import org.lanqiao.orm.EleUser;
import org.lanqiao.orm.LoginBean;
import org.lanqiao.service.ICheckLogin;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service("loginService")
public class CheckLogin implements ICheckLogin {
	
	@Resource
	private IEleManagerDao manager;
	@Resource
	private IEleUserDao user;
	@Resource
	private IEleOpeartorDao op;	
	@Resource
	private IEleInfoDao info;
	
	/* 实现管理员的登录验证
	 * @see org.lanqiao.service.ICheckLogin#ManagerLogin(org.lanqiao.orm.LoginBean)
	 */
	@Override
	@Transactional(rollbackFor={RuntimeException.class,Exception.class})
	public EleManager ManagerLogin(LoginBean bean) {
		//验证管理员的登录
		EleManager mana=new EleManager();
		mana.setManame(bean.getUsername());
		mana.setMapsw(bean.getUserpassword());
		return manager.selectLogin(mana);
	}


	@Override
	@Transactional(rollbackFor={RuntimeException.class,Exception.class})
	public EleUser UserLogin(LoginBean bean) {
		// 验证用户的登录
		EleUser userlogin=new EleUser();
		userlogin.setUsercard(bean.getUsername());
		userlogin.setUserpsw(bean.getUserpassword());
		return user.checkLoginUser(userlogin);
	}


	@Override
	public EleOpeartor OpeartorLogin(LoginBean bean) {
		//验证操作员的登录
		EleOpeartor oplogin=new EleOpeartor();
		oplogin.setOpcode(bean.getUsername());
		oplogin.setOppsw(bean.getUserpassword());
		return op.checkOpLogin(oplogin);
	}


	@Override
	public EleInfo selectInfo() {
		//查询最想的消息
		return info.selectNewInfo();
	}
}
